package com.ddogring.framework.config.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.ddogring.common.utils.DateUtils;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @BelongsProject: threelcsjava
 * @BelongsPackage: com.qp.framework.config.handler
 * @Author: DdogRing
 * @CreateTime: 2022-10-21  17:27
 * @Description: TODO 自动填充
 * @Version: 1.0
 */
@Component
public class MybatisMetaObjectHandler implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        this.strictInsertFill(metaObject, "createTime", Date.class, DateUtils.getDateNow());
        this.strictInsertFill(metaObject, "delFlag", () -> 0, Integer.class);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.strictInsertFill(metaObject, "updateTime", Date.class, DateUtils.getDateNow());
    }
}
